<template>
	<view class="page">
		<pageTxt>
			<!--  v-model="dataList" @query="queryList" -->
			<z-paging ref="paging" refresher-only @onRefresh="onRefresh" :paging-style="{ 'background-color': '#f7f7f7', height: '100%', width: '100%' }">
				<!-- 头部 -->
				<template slot="top">
					<u-navbar title="施工日志详情" :autoBack="true" :fixed="false"></u-navbar>
				</template>
				<!-- 内容 -->
				<view class="detail-content-box" v-if="dataObj">
					<u-empty
						v-if="!$fieldShowFunc('22-xmxx') && !$fieldShowFunc('22-xmxx')"
						marginTop="300rpx"
						icon="https://hzybucket.obs.cn-south-1.myhuaweicloud.com/we_chat/no-msg2.png"
						text=" "
					></u-empty>
					<view class="item-box" v-if="$fieldShowFunc('22-sgrz')">
						<view class="title">项目信息</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_xmmc')">
							<text class="txt">项目名称</text>
							<view class="content">
								{{ dataObj.project_name }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_xmbh')">
							<text class="txt">项目编号</text>
							<view class="content">
								<text class="txt-btn" @click="navToProjectFunc">
									{{ dataObj.project_number }}
								</text>
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_xmpp')">
							<text class="txt">项目品牌</text>
							<view class="content">
								{{ dataObj.brand_name }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_xmlx')">
							<text class="txt">项目类型</text>
							<view class="content">
								{{ dataObj.store_type_name }}
							</view>
						</view>
					</view>
					<view class="item-box" v-if="$fieldShowFunc('22-sgrz')">
						<view class="title">施工日志</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_sgjd')">
							<text class="txt">施工阶段</text>
							<view class="content">
								{{ dataObj.construction_stage || '--' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_fxbq')">
							<text class="txt">风险标签</text>
							<view class="content">
								{{ dataObj.risk_label || '--' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_xczpsp')">
							<text class="txt">现场照片/视频</text>
							<view class="content flex ac flex">
								<image
									v-for="(item, index) in dataObj.construction_files"
									:key="index"
									:src="$fileImgFunc(item)"
									@click="previewFunc(item)"
									mode="aspectFill"
									class="img-box"
								></image>
								<template v-if="!dataObj.construction_files.length">--</template>
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_sgnr')">
							<text class="txt">施工内容</text>
							<view class="content">
								{{ dataObj.content || '--' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_sfcq')">
							<text class="txt">是否超期</text>
							<view class="content">
								{{ dataObj.is_overdue == 1 ? '是' : '否' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_cqlx')">
							<text class="txt">超期类型</text>
							<view class="content">
								{{ dataObj.overdue_type || '--' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_yjwgrq')">
							<text class="txt">预计完工日期</text>
							<view class="content">
								{{ dataObj.overdue_completion_date || '--' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_cqyy')">
							<text class="txt">超期原因</text>
							<view class="content">
								{{ dataObj.reason_overdue || '--' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_cjr')">
							<text class="txt">创建人</text>
							<view class="content">
								{{ dataObj.handlers_name || '--' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_cjsj')">
							<text class="txt">创建时间</text>
							<view class="content">
								{{ dataObj.created_at || '--' }}
							</view>
						</view>
						<view class="item-box-item flex jb" v-if="$fieldShowFunc('rz_bz')">
							<text class="txt">备注</text>
							<view class="content">
								{{ dataObj.remark || '--' }}
							</view>
						</view>
					</view>
				</view>
			</z-paging>
		</pageTxt>
		<!-- 文件预览 -->
		<preFileCom :fileObj="fileObj" @onFileSuccess="fileObj = ''"></preFileCom>
	</view>
</template>

<script>
export default {
	data() {
		return {
			loading: true,
			dataList: [],
			tabIndex: 0,
			tablist: [
				{
					name: '项目信息'
				},
				{
					name: '施工日志'
				}
			],
			dataObj: ''
		};
	},
	onLoad(option) {
		this.constructionLogDetails(option.id);
	},
	methods: {
		onRefresh() {
			this.constructionLogDetails(this.dataObj.id);
			this.$refs.paging.complete();
		},
		tabClickFunc(e) {
			this.tabIndex = e.index;
		},
		// 详情
		constructionLogDetails(construction_log_id) {
			this.$Apipc
				.constructionLogDetails({
					construction_log_id
				})
				.then((res) => {
					console.log(res, '施工日志详情');
					if (res.code == 200) {
						this.dataObj = res.data;
					}
				});
		},
		// 预览
		previewFunc(item) {
			this.fileObj = item;
		},
		// 去详情项目
		navToProjectFunc() {
			uni.navigateTo({
				url: '/pagesB/projectDetail/projectDetail?id=' + this.dataObj.project_id
			});
		}
	}
};
</script>

<style lang="scss" scoped></style>
